package com.yt.base.util.json.tree;

import java.util.*;

// Referenced classes of package com.htsoft.core.json.tree:
//            Node, NodeIDComparator, NodeSnComparator

public class Children {

	public List list;

	public Children() {
		list = new ArrayList();
	}

	public int getSize() {
		return list.size();
	}

	public void addChild(Node node) {
		list.add(node);
	}

	public String toString() {
		StringBuffer result = new StringBuffer("[");
		for (Iterator it = list.iterator(); it.hasNext(); result.append(((Node) it.next()).toString()).append(","))
			;
		if (!list.isEmpty())
			result.deleteCharAt(result.length() - 1);
		result.append("]");
		return result.toString();
	}

	public void sortChildren() {
		Collections.sort(list, new NodeIDComparator());
		for (Iterator it = list.iterator(); it.hasNext(); ((Node) it.next()).sortChildren())
			;
	}

	public void sortSnChildren() {
		Collections.sort(list, new NodeSnComparator());
		for (Iterator it = list.iterator(); it.hasNext(); ((Node) it.next()).sortSnChildren())
			;
	}

}
